<?php
 /**
   * This file contains functions for inital setup of a new project using the phpappmachine.  
   *  It will create the new directory structure, fill library files, and setup the basic database conneciton file
   * @package mypackage
   */
   
include_once "../../qc_base.php";
include_once "../../qc_utils.php";
include_once "../../bootstrap.php";

function setup_file_structure($project_id){


	$q = Doctrine_Query::create()
	->from('Projects p')->where('project_id = ?',$project_id);
	$project = $q->execute()->getFirst();	
	
	$project_db = $project->project_db;
	$project_path = $project->project_path;
	$project_server = $project->project_server;
	$project_login = $project->project_login;
	$project_pass = $project->project_pass;
   	$project_name = $project->project_name;
	$class_subpath = $project->class_subpath;
	$template_dir = $project->template_dir;	
	$structure = $project->file_structure;
	
	// Adjust variables:
    	// This will be the path without the last slash
	$project_path = QC_PROJECT_SUBPATH . $project_path;
	$full_project_path = QC_SYS_BASEDIR . '/' . $project_path;
	$structure_path = QC_SYS_BASEDIR . '/structures/';

 	smartCopy($structure_path  . $structure . '/' . 'structure',QC_SYS_BASEDIR . '/' .QC_PROJECT_SUBPATH );
	rename(QC_SYS_BASEDIR . '/' .QC_PROJECT_SUBPATH  . '/structure/', QC_SYS_BASEDIR . '/' . $project_path);

}
?>
